e34a2c75624893e601a48b50e1f20d0bb6bd3c78,portal-impl/src/com/liferay/portal/lar/LayoutImporter.java,LayoutImporter,importLayouts,#number#number#boolean#Map#File#,112
Before Change
Map<Long, Layout> newLayoutIdPlidMap =
(Map<Long, Layout>)context.getNewPrimaryKeysMap(Layout.class);
List<Element> layoutEls = root.element("layouts").elements("layout");
if (_log.isDebugEnabled()) {
if (layoutEls.size() > 0) {
_log.debug("Importing layouts");
}
}
for (Element layoutRefEl : layoutEls) {
importLayout(
context, user, layoutCache, previousLayouts, newLayouts,
newLayoutIdPlidMap, newLayoutIds, portletsMergeMode, themeId,
colorSchemeId, layoutsImportMode, privateLayout,
importPermissions, importUserPermissions, useThemeZip, root,
layoutRefEl);
}
List<Element> portletEls = root.element("portlets").elements("portlet");
// Delete portlet data
if (deletePortletData) {
if (_log.isDebugEnabled()) {
if (portletEls.size() > 0) {
_log.debug("Deleting portlet data");
}
}
for (Element portletRefEl : portletEls) {
String portletId = portletRefEl.attributeValue("portlet-id");
long layoutId = GetterUtil.getLong(
portletRefEl.attributeValue("layout-id"));
long plid = newLayoutIdPlidMap.get(layoutId).getPlid();
context.setPlid(plid);
_portletImporter.deletePortletData(context, portletId, plid);
}
}
// Import portlets
if (_log.isDebugEnabled()) {
if (portletEls.size() > 0) {
_log.debug("Importing portlets");
}
}
for (Element portletRefEl : portletEls) {
String portletPath = portletRefEl.attributeValue("path");
String portletId = portletRefEl.attributeValue("portlet-id");
long layoutId = GetterUtil.getLong(
portletRefEl.attributeValue("layout-id"));
long plid = newLayoutIdPlidMap.get(layoutId).getPlid();
long oldPlid = GetterUtil.getLong(
portletRefEl.attributeValue("old-plid"));
Layout layout = LayoutUtil.findByPrimaryKey(plid);
context.setPlid(plid);
context.setOldPlid(oldPlid);
Element portletEl = null;
try {
Document portletDoc = SAXReaderUtil.read(
context.getZipEntryAsString(portletPath));
portletEl = portletDoc.getRootElement();
}
catch (DocumentException de) {
throw new SystemException(de);
}
// The order of the import is important. You must always import
// the portlet preferences first, then the portlet data, then
// the portlet permissions. The import of the portlet data
// assumes that portlet preferences already exist.
// Portlet preferences
_portletImporter.importPortletPreferences(
context, layoutSet.getCompanyId(), layout.getGroupId(),
layout, null, portletEl, importPortletSetup,
importPortletArchivedSetups, importPortletUserPreferences,
false);
// Portlet data scope
long scopeLayoutId = GetterUtil.getLong(
portletEl.attributeValue("scope-layout-id"));
context.setScopeLayoutId(scopeLayoutId);
// Portlet data
Element portletDataEl = portletEl.element("portlet-data");
if (importPortletData && (portletDataEl != null)) {
_portletImporter.importPortletData(
After Change
Map<Long, Layout> newLayoutsMap =
(Map<Long, Layout>)context.getNewPrimaryKeysMap(Layout.class);
Element layoutsElement = rootElement.element("layouts");
List<Element> layoutElements = layoutsElement.elements("layout");
if (_log.isDebugEnabled()) {
if (layoutElements.size() > 0) {
_log.debug("Importing layouts");
}
}
for (Element layoutElement : layoutElements) {
importLayout(
context, user, layoutCache, previousLayouts, newLayouts,
newLayoutsMap, newLayoutIds, portletsMergeMode, themeId,
colorSchemeId, layoutsImportMode, privateLayout,
importPermissions, importUserPermissions, useThemeZip,
rootElement, layoutElement);
}
Element portletsElement = rootElement.element("portlets");
List<Element> portletElements = portletsElement.elements("portlet");
// Delete portlet data
if (deletePortletData) {
if (_log.isDebugEnabled()) {
if (portletElements.size() > 0) {
_log.debug("Deleting portlet data");
}
}
for (Element portletElement : portletElements) {
String portletId = portletElement.attributeValue("portlet-id");
long layoutId = GetterUtil.getLong(
portletElement.attributeValue("layout-id"));
long plid = newLayoutsMap.get(layoutId).getPlid();
context.setPlid(plid);
_portletImporter.deletePortletData(context, portletId, plid);
}
}
// Import portlets
if (_log.isDebugEnabled()) {
if (portletElements.size() > 0) {
_log.debug("Importing portlets");
}
}
for (Element portletElement : portletElements) {
String portletPath = portletElement.attributeValue("path");
String portletId = portletElement.attributeValue("portlet-id");
long layoutId = GetterUtil.getLong(
portletElement.attributeValue("layout-id"));
long plid = newLayoutsMap.get(layoutId).getPlid();
long oldPlid = GetterUtil.getLong(
portletElement.attributeValue("old-plid"));
Layout layout = LayoutUtil.findByPrimaryKey(plid);
context.setPlid(plid);
context.setOldPlid(oldPlid);
Document portletDocument = SAXReaderUtil.read(
context.getZipEntryAsString(portletPath));
portletElement = portletDocument.getRootElement();
// The order of the import is important. You must always import
// the portlet preferences first, then the portlet data, then
// the portlet permissions. The import of the portlet data
// assumes that portlet preferences already exist.
// Portlet preferences
_portletImporter.importPortletPreferences(
context, layoutSet.getCompanyId(), layout.getGroupId(),
layout, null, portletElement, importPortletSetup,
importPortletArchivedSetups, importPortletUserPreferences,
false);
// Portlet data scope
long scopeLayoutId = GetterUtil.getLong(
portletElement.attributeValue("scope-layout-id"));
context.setScopeLayoutId(scopeLayoutId);
// Portlet data
Element portletDataElement = portletElement.element("portlet-data");
if (importPortletData && (portletDataElement != null)) {
_portletImporter.importPortletData(